<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: XListMenuPortlet.php 289 2008-11-14 05:34:40Z steen.rabol@gmail.com $
 *
 */

Prado::using('Application.Common.XListMenu');
Prado::using('Application.Portlets.Portlet');
class XListMenuPortlet extends Portlet
{
	public function onLoad($param)
	{
		parent::onLoad($param);

		$mainmenu	= new XListMenu();
		$mainmenu->ActiveCssClass	= ""; //"xlistmenu-active";
		$mainmenu->InactiveCssClass	= ""; //"xlistmenu-inactive";
		$mainmenu->CssClass			= ""; //"xlistmenu";

		$pages		= $this->DataAccess->createCommand("select * from tblpages where active=1 order by displayorder")->query();

		if($pages !== null && $pages !== false)
		{
			$am	= $this->Application->getModule('auth');
			foreach($pages as $page)
			{
				if($am->CanView($page['name']))
				{
					$mi					= new XListMenuItem();
					$mi->PagePath		= $page['name'];
					$mi->NavigateUrl	= $this->Service->constructUrl($page['name']);
					$mi->Text			= $page['displayname'];
					$mainmenu->Controls[] = $mi;
				}
			}
		}

		$this->XListMenuPlaceholder->Controls[] = $mainmenu;
	}
}
?>